//
//  LYBaseViewController.swift
//  Swift---新浪微博练习代码
//
//  Created by Mr.Yan on 2017/6/30.
//  Copyright © 2017年 Mr.Yan. All rights reserved.
//

import UIKit

class LYBaseViewController: UIViewController {
    //判断登陆
    let isLogin: Bool = false
//设置全局访问的visitorView
    var visitorView:LYVisitorView?
    override func loadView() {
        if !isLogin {//未登录
            setupVisitorView()
        }else{//登陆成功
        super.loadView()
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupNav()
    }

  private  func setupNav(){
    
    navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: nil, title: "注册", tager: self, action: #selector(loginClick))
    navigationItem.rightBarButtonItem = UIBarButtonItem(imageName: nil, title: "登陆", tager: self, action: #selector(loginClick))
    }
   @objc private func loginClick(){
    
        
    
    }
    //设置访客视图view
    private func setupVisitorView(){
    
        //实例化LYVisitorView
        visitorView = LYVisitorView()
        //02实例化闭包
        visitorView?.closure = {[weak self] in
        
            //04执行闭包
            self?.loginClick()
        }
        view = visitorView
        setupNav()
    
    }
    
}
